package com.mk.admin.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.mk.admin.mapper.MessageRecordMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.MessageRecordEntity;
import com.mk.admin.model.vo.MessageRecordVo;
import com.mk.admin.service.MessageReadService;
import com.mk.admin.service.MessageRecordService;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageRecordServiceImpl implements MessageRecordService {

    @Autowired
    private MessageRecordMapper messageRecordMapper;

    @Override
    public ResultDto getMsgByid(MessageRecordVo vo) {
        MessageRecordEntity entity = JSONCopy.copy(vo, MessageRecordEntity.class);
        return ResultDto.data(messageRecordMapper.count(entity),messageRecordMapper.select(entity));
    }

    @Override
    public ResultDto addBatch(List<MessageRecordVo> list) {
        return ResultDto.data("success");
    }

    @Override
    public ResultDto add(MessageRecordVo messageRecordVo) {
        return ResultDto.data(messageRecordMapper.insert(JSONCopy.copy(messageRecordVo, MessageRecordEntity.class)));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(messageRecordMapper.deleteById(id));
    }


}
